 function [X]=sylvester(A,B,C,flag)
 // Generated by lmitool on Thu Feb 09 11:55:34 MET 1995
   
   Mbound = 1e3;
   abstol = 1e-10;
   nu = 10;
   maxiters = 100;
   reltol = 1e-10;
   options=[Mbound,abstol,nu,maxiters,reltol];
    
 ///////////DEFINE INITIAL GUESS AND PRELIMINARY CALCULATIONS BELOW
 [na,ma]=size(A);[nb,mb]=size(B)                                   
 if ma<>na|mb<>nb then error("invalid dimensions");end             
 X_init=zeros(ma,nb)                                               
 /////////// 
  
 XLIST0=list(X_init)
 XLIST=lmisolver(XLIST0,sylvester_eval,options)
 [X]=XLIST(:)
  
  
  
 /////////////////EVALUATION FUNCTION////////////////////////////
  
 function [LME,LMI,OBJ]=sylvester_eval(XLIST)
 [X]=XLIST(:)
  
 /////////////////DEFINE LME, LMI and OBJ BELOW
 if flag=='c' then LME=A*X+X*B-C                                   
 else LME=A*X*B-C                                                  
 end                                                               
 LMI=[]                                                            
 OBJ=[]                                                            
                                                                   
                                                                   
